package com.trace.mybatis.sqlsession;

import com.trace.mybatis.cfg.Configuration;
import com.trace.mybatis.defaults.DefaultSqlSessionFactory;
import com.trace.mybatis.utils.XMLConfigBuilder;

import java.io.InputStream;

/**
 * @author 沈泽群
 * @date 2020/8/3
 */
public class SqlSessionFactoryBuilder {

    /**
     * 根据字节输入流创建sqlSessionFactory
     * @param inputStream
     * @return
     */
    public SqlSessionFactory build(InputStream inputStream){
        Configuration cfg = XMLConfigBuilder.loadConfiguration(inputStream);
        return new DefaultSqlSessionFactory(cfg);
    }
}
